package com.example.cloud.lijianhystrix;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@EnableCircuitBreaker
@ComponentScan
@RestController
@EnableEurekaClient
@SpringBootApplication
// @SpringCloudApplication , 可以查看该注解，是上面三个注解的集合
public class LijianEurekaHystrixApplication {
    @RequestMapping("/")
    public String home() {
        return "Hello world ,this is test eureka client ";
    }

    @Value("${server.port}")
    String port;

    @RequestMapping("/showport")
    public String showport() {
        return "from port:" + port;
    }

    @Bean
    @LoadBalanced
    RestTemplate restTemplate() {
        return new RestTemplate();
    }


    public static void main(String[] args) {
        SpringApplication.run(LijianEurekaHystrixApplication.class, args);
    }
}
